package com.team.childapp.ui.setting

import android.content.Intent
import android.provider.Settings
import android.text.TextUtils
import android.view.KeyEvent
import android.view.View
import android.widget.Toast
import androidx.core.content.ContextCompat
import com.team.childapp.R
import com.team.childapp.base.activity.BaseActivity
import com.team.childapp.base.listener.ICallBackResultListener
import com.team.childapp.databinding.ActivitySettingAgeBinding
import com.team.childapp.databinding.ActivitySettingsBinding
import com.team.childapp.http.LoginLogical
import com.team.childapp.ui.MainActivity
import com.team.childapp.ui.dialog.DatePickerDialogFragment

/**
 * Create on: 2024/12/26
 * by Mr.Zhu
 * Description: 设置信息页面
 */
class SettingActivity : BaseActivity<ActivitySettingsBinding>(R.layout.activity_settings) {
    private var currentSelect : Int = 1 //当前默认头像选择
    private var currentSex : Int = 0 //性别 0 是男 1是女
    private lateinit var datePickerDialogFragment: DatePickerDialogFragment
    override fun initData() {
        // 绑定设置项视图
//        val profileSetting: View = findViewById(R.id.profileSetting)
        val wifiSetting: View = findViewById(R.id.wifiSetting)
        val volumeSetting: View = findViewById(R.id.volumeSetting)

        // 设置点击事件
//        profileSetting.setOnClickListener {
//            openProfileSettings()
//        }

        wifiSetting.setOnClickListener {
            openWifiSettings()
        }

        volumeSetting.setOnClickListener {
            openVolumeSettings()
        }

        // 绑定底部导航栏图标
        val rightIcon: View = findViewById(R.id.rightIcon)


        rightIcon.setOnClickListener {
            // 处理右侧图标点击事件
            onRightIconClicked()
        }
    }

    private fun openProfileSettings() {
        // 跳转到个人资料设置页面
//        val intent = Intent(this, ProfileSettingsActivity::class.java)
//        startActivity(intent)
    }

    private fun openWifiSettings() {
        // 跳转到无线网设置页面
        val intent = Intent(Settings.ACTION_WIFI_SETTINGS) // 打开无线网络设置页面
        startActivity(intent)
    }

    private fun openVolumeSettings() {
        // 跳转到音量设置页面
        val intent = Intent(Settings.ACTION_SOUND_SETTINGS) // 打开声音设置页面
        startActivity(intent)
    }

    private fun onLeftIconClicked() {
        // 处理左侧图标点击事件
        val intent = Intent(this, MainActivity::class.java)
        startActivity(intent)
    }

    private fun onRightIconClicked() {
        // 处理返回图标点击事件
        val intent = Intent(this, MainActivity::class.java)
        startActivity(intent)
    }
    override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
        if (keyCode == KeyEvent.KEYCODE_F2) {
            val intent = Intent(this, MainActivity::class.java)
            startActivity(intent)
            overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
            return true
        }
        if (keyCode == KeyEvent.KEYCODE_BACK ) {
            start<MainActivity>()
            overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left)
            return true // 表示事件已处理
        }
        return super.onKeyDown(keyCode, event)
    }

}